package hu.bme.mit.inf.expendables.entities;
	
import javax.persistence.*;
import hu.bme.mit.inf.expendables.entities.*;
import java.util.List;
import java.util.ArrayList;


@Entity
@Table(name="T_ACCOUNT")
@NamedQueries(
	{
	@NamedQuery(name=Account.UPDATE_BALANCE,query="UPDATE Account a SET a.balance = a.balance+:amount WHERE a.accountId = :accountId"),
	@NamedQuery(name=Account.GET_ACCOUNT,query="SELECT c FROM Account c WHERE c.accountId = :accountId")
	})
public class Account {
	                        	
	public static final String UPDATE_BALANCE = "UpdateBalance";
	public static final String GET_ACCOUNT = "GetAccount";

	//Attributes
	private float balance;
	
	@Id
	@GeneratedValue
	@Column(name="ACCOUNT_ID")
	private long accountId;
	

	//Reference to User
	@OneToOne(mappedBy="account")
	private User user;
	


	//Getters and Setters
	public float getBalance(){
		return balance;
	}
	
	public void setBalance(float balance){
		this.balance = balance;
	}
	
	public long getAccountId(){
		return accountId;
	}
	
	public void setAccountId(long accountId){
		this.accountId = accountId;
	}
	

	public User getUser(){
		return user;
	}
	
	public void setUser(User user){
		this.user = user;
	}
		
}